package com.liwei.vip.mall.goods.controller;

import com.liwei.mall.util.RespResult;
import com.liwei.vip.mall.goods.model.Sku;
import com.liwei.vip.mall.goods.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sku")
public class SkuController {
    @Autowired
    private SkuService skuService;

    /**
     * 根据推广产品分类ID查询指定分类下的产品列表
     * @param id
     * @return
     */
    @GetMapping("/adItems/type")
    public List<Sku> typeItems(@RequestParam(value="id") Integer id){
        return skuService.typeSkuItems(id);
    }

    /**
     * 根据分类id删除指定推广的数据
     * @param id
     * @return
     */
    @DeleteMapping("/adItems/type")
    public RespResult deltypeItems(@RequestParam(value="id") Integer id){
        skuService.deltypeSkuItems(id);
        return RespResult.ok();
    }

    /**
     * 根据分类id修改指定推广数据
     *
     * @param id
     */
    @PutMapping("/adItems/type")
    public RespResult updateTypeItems(@RequestParam(value="id") Integer id){
        skuService.updatetypeSkuItems(id);
        return RespResult.ok();
    }
}
